package com.fxnotes.common.ui.components;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.stage.Window;

public class ModalDialogBuilder {

    private Window owner;
    private String title;
    private Integer width;
    private Integer height;
    private Node content;
    private ButtonInfo confirmationButton;
    private ButtonInfo cancelButton = new ButtonInfo("Cancel");

    public ModalDialogBuilder owner(Window owner) {
        this.owner = owner;
        return this;
    }

    public ModalDialogBuilder title(String title) {
        this.title = title;
        return this;
    }

    public ModalDialogBuilder height(int height) {
        this.height = height;
        return this;
    }

    public ModalDialogBuilder width(int width) {
        this.width = width;
        return this;
    }

    public ModalDialogBuilder content(Node content) {
        this.content = content;
        return this;
    }

    public ModalDialogBuilder confirmationButton(String name, EventHandler<ActionEvent> handler) {
        this.confirmationButton = new ButtonInfo(name, handler);
        return this;
    }

    public ModalDialogBuilder cancelButton(String name) {
        this.cancelButton = new ButtonInfo(name);
        return this;
    }

    public ButtonInfo getCancelButton() {
        return cancelButton;
    }

    public ButtonInfo getConfirmationButton() {
        return confirmationButton;
    }

    public Node getContent() {
        return content;
    }

    public Integer getHeight() {
        return height;
    }

    public Window getOwner() {
        return owner;
    }

    public String getTitle() {
        return title;
    }

    public Integer getWidth() {
        return width;
    }

    public static ModalDialogBuilder create() {
        return new ModalDialogBuilder();
    }
            
    public ModalDialog build() {
        return new ModalDialog(this);
    }
}